let t;
let num = 30;

function run(){
    if(num<0){
        let btn  =document.getElementById('sendcode');
        btn.classList.remove('am-disabled');
        btn.value = '发送验证码';
        clearTimeout(t);
        num = 30;
        return false;
    }
    $("#sendcode").val(`${num}s后重发`);
    --num;
    t=setTimeout("run()",1000)
}
function email(e)
{
    let btn = document.getElementById('sendcode');
    btn.classList.add('am-disabled');
    clearInterval(t);
    run();
    
      $.ajax({
         url:"/user/User/sendemail",
         type:"post",
         dataType:"html",
         data:{toemail:e},
         success:function(data)
         {
         },
         error:function()
         {
         }
     }) 
}
function confirmpasswordCheck(){
    let tip = document.getElementById('tip');
    let btn = document.getElementById('comfirm');
    let newpw = document.getElementById('new_password');
    let cnewpw = document.getElementById('confirm_password');
    if(cnewpw.value != ''){
        if(newpw.value != cnewpw.value){
            tip.style.display = 'block';
            btn.classList.add('am-disabled');
        }else{
            btn.classList.remove('am-disabled');
            tip.style.display = 'none';
        }
    }else{
        if(cnewpw.value == ''){
            btn.classList.add('am-disabled');
            return
        }
        if(newpw.value == '' || cnewpw.value == ''){
            tip.style.display = 'none';
            btn.classList.add('am-disabled');
            return
        }
    }
}
